package cn.edu.sysu.dto;

import java.util.Date;

public class SolutionDto {

	String code;
	Date post_time;
	int problem_id;
	int revision;
	int user_id;
	int correct;

	String htmlCode = null;

	public SolutionDto(String code, Date post_time, int problem_id, int revision, int user_id, int correct) {
		super();
		this.code = code;
		this.post_time = post_time;
		this.problem_id = problem_id;
		this.revision = revision;
		this.user_id = user_id;
		this.correct = correct;
	}

	public String getCode() {
		if (null == htmlCode) {
			htmlCode = code.replaceAll("<", "&lt;").replaceAll(">", "&gt;");
		}
		return htmlCode;
	}

	public void setCode(String code) {

		this.code = code;
	}

	public Date getPost_time() {
		return post_time;
	}

	public void setPost_time(Date post_time) {
		this.post_time = post_time;
	}

	public int getProblem_id() {
		return problem_id;
	}

	public void setProblem_id(int problem_id) {
		this.problem_id = problem_id;
	}

	public int getRevision() {
		return revision;
	}

	public void setRevision(int revision) {
		this.revision = revision;
	}

	public int getUser_id() {
		return user_id;
	}

	public void setUser_id(int user_id) {
		this.user_id = user_id;
	}

	public int getCorrect() {
		return correct;
	}

	public void setCorrect(int correct) {
		this.correct = correct;
	}

	public String getCorrectString() {
		switch (this.correct) {
		case 99:
			return "Unknow";
		case 1:
			return "Correct";
		case 0:
			return "Wrong";

		default:
			return "Unexpected";
		}
	}

}
